package com.datasync.conf;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Getter
@Setter
@Configuration
@ConfigurationProperties(prefix = "sync.jobs")
public class SyncJobProperties {
    private String jobName;
    private String sourceTable;
    private String targetTable;
    private List<FieldMapping> fieldMappings;
    private String syncMode;
    private String cron;

    public Map<String, String> getFieldMappings() {
        return fieldMappings.stream()
                .collect(Collectors.toMap(
                        FieldMapping::getSrcField,
                        FieldMapping::getTgtField)
                );
    }

    @Getter
    @Setter
    public static class FieldMapping {
        private String srcField;
        private String tgtField;
    }
}